package com.leyou.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.leyou.entity.OrderEntity;
import com.leyou.service.OrderService;

import com.leyou.api.R;



/**
 * 
 *
 * @author Daifeng
 * @email 2661184062@qq.com
 * @date 2020-12-25 16:44:48
 */
@RestController
@RequestMapping("leyou/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 信息
     */
    @RequestMapping("/info/{orderId}")
 //   @RequiresPermissions("leyou:order:info")
    public R info(@PathVariable("orderId") Long orderId){
		OrderEntity order = orderService.getById(orderId);

        return R.ok().put("order", order);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
  //  @RequiresPermissions("leyou:order:save")
    public R save(@RequestBody OrderEntity order){
		orderService.save(order);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
  //  @RequiresPermissions("leyou:order:update")
    public R update(@RequestBody OrderEntity order){
		orderService.updateById(order);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
   // @RequiresPermissions("leyou:order:delete")
    public R delete(@RequestBody Long[] orderIds){
		orderService.removeByIds(Arrays.asList(orderIds));

        return R.ok();
    }

}
